package com.example.waibao.controller;

import com.example.waibao.Component.UserHelper;
import com.example.waibao.entity.ResponseResult;
import com.example.waibao.entity.ResponseResult2;
import com.example.waibao.entity.User;
import com.example.waibao.service.loginService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class loginController {


    @Autowired
    private UserHelper userHelper;

    @Autowired
    private loginService loginService;

    @PostMapping("/user/login")
    public ResponseResult login(@RequestBody User user){
        System.out.println("从前端得到的用户账号密码信息："+user);
        return loginService.login(user);
    }

    @PostMapping("/user/logout")
    public ResponseResult logout(){
        return loginService.logout();
    }

    //
    @PostMapping("/hello")
    @PreAuthorize("hasAuthority('system:dept:list')")    //需要test权限才能访问
    public String hello(){
        return "hello";
    }


    //设置用户头像


    //学校注册




}



















//package com.example.waibao.controller;
//
//import com.example.waibao.bean.req.loginReq;
//import com.example.waibao.service.loginService;
//import org.springframework.web.bind.annotation.GetMapping;
//import org.springframework.web.bind.annotation.PostMapping;
//import org.springframework.web.bind.annotation.RequestMapping;
//import org.springframework.web.bind.annotation.RestController;
//
//import javax.annotation.Resource;
//
//@RestController
//public class loginController {
//    @Resource
//    private loginService loginService;
//
//    @GetMapping("/selectById")
//    public String selectById(int id){ return  "idxxxx"; }
//
//    @PostMapping("/login")
//    public String login(loginReq loginReq) {
//
//        return loginService.login(loginReq);
//
//    }
//
//
//
//
//
//
//    }
